/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package common;

import java.io.Serializable;
import java.util.Random;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

/**
 *
 * @author Jadalbert
 */
@ManagedBean
@ViewScoped
public class tools implements Serializable {
    private double N_kN;
    private Random generator = new Random();
    private int rnd;
    private String text;

    /**
     * Creates a new instance of tools
     */
    public tools() {
    }
    
    public void msg() {
        addMessage("msg");
    }
    
    public String getText() {
        return Integer.toString(rnd);
    }
    
    public void setText(String text) {
        this.text = text;
    }
    
    /**
     * metoda zaokrąglania wyników
     * @param value 
     */
    public double round(double value, int precision) {
        double factor_ = (long)Math.pow(10, precision);
        value = value * factor_;
        long value_ = Math.round(value);
        return (double)value_ / factor_;
    }     

    /**
     * @return the N_kN
     */
    public double getN_kN() {
        return 0.001;
    }
    
    public void addMessage(String summary) {  
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary,  null);  
        FacesContext.getCurrentInstance().addMessage(null, message);  
    }    
}
